import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: () => import('@/views/login.vue')
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: () => import('@/views/error-page/404.vue')
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: () => import('@//views/error-page/403.vue')
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: () => import('@/views/error-page/500.vue')
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: () => import('@/views/main-components/lockscreen/components/locking-page.vue')
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/home',
    component: Main,
    children: [
        { path: 'home', title: {i18n: 'home'}, name: 'home_index', component: () => import('@/views/home/home.vue') },
        { path: 'system/manager/manager_add', title: '管理员添加', name: 'manager_add', access: 'user:save', component: () => import('@/views/system/manager/manager-add.vue') },
        { path: 'system/manager/manager_edit/:id', title: '管理员编辑', name: 'manager_edit', access: 'user:update', component: () => import('@/views/system/manager/manager-edit.vue') },
        { path: 'member/member_info/:openId', title: '会员信息卡', name: 'member_info', access: 'memberInfo:list', component: () => import('@/views/member/member-info.vue') },

        { path: 'news-add', title: '新闻添加', name: 'news_add', icon: 'chevron-right', access: 'news:save',component: () => import('@/views/news/news-add.vue') },
        { path: 'news-edit/:id', title: '新闻编辑', name: 'news_edit', icon: 'chevron-right', access: 'news:update',component: () => import('@/views/news/news-edit.vue') }
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/system',
        icon: 'social-windows',
        name: 'system',
        title: '系统管理',
        component: Main,
        children: [
            { path: 'manager', title: '管理员列表', name: 'manager-index', icon: 'chevron-right',access: 'user:list', component: () => import('@/views/system/manager/manager-index.vue') },
            { path: 'role', title: '角色列表', name: 'role-index', icon: 'chevron-right', access: 'role:list',component: () => import('@/views/system/role/role.vue') },
            { path: 'menu', title: '菜单列表', name: 'menu-index', icon: 'chevron-right', access: 'menu:list',component: () => import('@/views/system/menu/menu-index.vue') },
            { path: 'city', title: '城市管理', name: 'city-index', icon: 'chevron-right', access: 'city:list',component: () => import('@/views/system/city/city-index.vue') },
            { path: 'company', title: '公司管理', name: 'company-index', icon: 'chevron-right', access: 'company:list',component: () => import('@/views/system/company/company-index.vue') },
            { path: 'dict', title: '字典管理', name: 'dict-index', icon: 'chevron-right', access: 'dict:list',component: () => import('@/views/system/dict/dict-index.vue') }
        ]
    },
    {
        path: '/monitor',
        icon: 'ios-videocam',
        name: 'monitor',
        title: '监控管理',
        component: Main,
        children: [
            { path: 'login-log', title: '登录日志', name: 'loginLog', icon: 'chevron-right',access: 'log:loginList', component: () => import('@/views/monitor/login-log/loginLog.vue') },
            { path: 'operation-log', title: '操作日志', name: 'operationLog', icon: 'chevron-right', access: 'log:logList',component: () => import('@/views/monitor/operation-log/operationLog.vue') }
        ]
    },
    {
        path: '/news',
        icon: 'flag',
        name: 'news',
        title: '新闻管理',
        component: Main,
        children: [
            { path: 'news-list', title: '新闻列表', name: 'news-index', icon: 'chevron-right', access: 'news:list',component: () => import('@/views/news/news-index.vue') }
            
        ]
    },
    {
        path: '/member',
        icon: 'android-people',
        name: 'member',
        title: '用户管理',
        component: Main,
        children: [
            { path: 'member-index', title: '用户列表', name: 'member-index', icon: 'ios-list',access: 'member:list', component: () => import('@/views/member/member-index.vue') },
        ]
    },
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    locking,
    ...appRouter,
    page500,
    page403,
    page404
];
